package pri.zey.custom.tools.http;

import android.content.Context;

import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.HttpURLConnection;

/**
 * Created by Administrator on 2016/3/9.
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>基础描述
 * ZHttpBase和ZHttpService的桥梁
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>属性描述
 *
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>方法描述
 *
 */
public abstract class ZHttpAgency <T> extends ZHttpBase {

    protected int TimeOut = 2 * 1000;
    protected int mRequestMethod = 1;
    protected Object mObject;
    protected String mMethod;
    protected Context mContext;

    protected HttpURLConnection mConnection;
    protected PrintWriter mPrintWriter;
    protected BufferedReader mReaderBuffer;
    protected StringBuffer mOutBuffer = new StringBuffer(), mInputBuffer = new StringBuffer();

    protected RequestSuccess mSuccess;
    protected RequestFail mFail;

    /**
     * 设置发送内容
     */
    public abstract void setOutBuffer();

    /**
     * 连接设置初始
     */
    public abstract void setConnectionConfig();

    /**
     * 根据连接方式处理
     */
    public abstract void setConnectionType();

    /**
     * 数据转换
     */
    public abstract JSONObject setReaderBuffer();

    /**
     * 获取结果
     * @param inputStream
     */
    public abstract T getReader(InputStream inputStream);

    /**
     * 关闭流对象
     */
    public abstract void closeObject();
}
